﻿using Bit.Art.Core.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;

namespace Bit.Art.Db
{
    public class ExchangeConfigDb : DbContext
    {
        public DbSet<Market> Markets { get; set; }

        public DbSet<UpdateBalancePermission> UpdateBalancePermission { get; set; }

        public DbSet<CoinInfo> CoinInfo { get; set; }

        public ExchangeConfigDb() { }

        public ExchangeConfigDb(DbContextOptions<ExchangeConfigDb> options)
            : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<Market>().Property(m => m.Name).HasMaxLength(20);
            modelBuilder.Entity<UpdateBalancePermission>().Property(m => m.Coin).HasMaxLength(10);
            modelBuilder.Entity<UpdateBalancePermission>().Property(m => m.AppId).HasMaxLength(64);

            modelBuilder.Entity<CoinInfo>().Property(m => m.Name).HasMaxLength(64);
            modelBuilder.Entity<CoinInfo>().Property(m => m.Symbol).HasMaxLength(10);
            modelBuilder.Entity<CoinInfo>().Property(m => m.ThirdPartyOwner).HasMaxLength(32);
            modelBuilder.Entity<CoinInfo>().Property(m => m.LogoUrl).HasMaxLength(255);
        }
    }
}
